// 处理路径别名的模块
require('module-alias/register');
// 使用koa2启动本地服务作为数据mock
const Koa = require('koa');
const Router = require('koa-router');
const bodyparser = require('koa-bodyparser');
const logger = require('koa-logger');
const routerModel = require('@/router');

const port = 9001;

const app = new Koa();

// 解析json格式
app.use(bodyparser({
  enableTypes: ['json', 'form', 'text'],
}));
// 输出访问记录
app.use(logger());

const router = new Router();

// 加载用户路由
routerModel.install(router);

app.use(router.routes(), router.allowedMethods());

app.listen(port, () => {
  console.log(`the service running at: localhost:${port}`);
});